import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';

import '../../resources.dart';

/// created by hcl
/// on 2025/2/10
/// AgreementPage
/// desc
class AgreementPage extends StatelessWidget {
  const AgreementPage({super.key});

  @override
  Widget build(BuildContext context) {
    var arguments = ModalRoute.of(context)?.settings.arguments;
    String title = '';
    String url = '';
    if (arguments != null && arguments is Map<String, dynamic>) {
      title = arguments['title'] ?? '';
      url = arguments['url'] ?? 0;
    }
    return Scaffold(
      backgroundColor: ColorUtils.color_FFFFFF,
      body: Center(
        child: SizedBox(
          width: designWidth.ss,
          child: Column(
            children: [
              commonTitleBar(title, onTap: () {
                Nav.pop();
              }),
              Expanded(
                  child: InAppWebView(
                initialSettings:
                    InAppWebViewSettings(cacheMode: CacheMode.LOAD_NO_CACHE),
                onWebViewCreated: (webController) {
                  webController.loadUrl(
                      urlRequest: URLRequest(url: WebUri(url.replaceAll('http://', 'https://'))));
                },
              ))
            ],
          ),
        ),
      ),
    );
  }
}
